package araxy.blog.task;

import araxy.blog.TotalStatus;
import araxy.blog.utils.DateUtil;
import araxy.blog.utils.GitUtil;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

public class GitSyncJob extends QuartzJobBean {

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        if (!TotalStatus.isGit()) {
            return;
        }
        try {
            GitUtil.commitAll(DateUtil.getSysTime());
            GitUtil.push();
        } catch (GitAPIException ignored) {

        }
    }
}
